
public class RockPaperScissors {
	
	Result play(RPSEnum p1, RPSEnum p2){
		
		Result resultat = null;
		
		switch(p1){
		
		case PAPER:
			
			switch(p2){
			
			case PAPER:
				resultat = Result.TIE;
			break;
			
			case ROCK:
				resultat = Result.WIN;
			break;
				
			case SCISSORS:
				resultat = Result.LOST;
			break;
			}
			
			break;
			
			
		case ROCK:
			
			switch(p2){
			
			case PAPER:
				resultat = Result.LOST;
			break;
			
			case ROCK:
				resultat = Result.TIE;
			break;
				
			case SCISSORS:
				resultat = Result.WIN;
			break;
			}
			
			break;
			
		case SCISSORS:
			
			switch(p2){
			
			case PAPER:
				resultat = Result.WIN;
			break;
			
			case ROCK:
				resultat = Result.LOST;
			break;
				
			case SCISSORS:
				resultat = Result.TIE;
			break;
			}
			
			break;
		
		
		}
		
		return resultat;
		
		
		
		
		
	}
	
	Result play(Player p1, Player p2){
		
		Result resultat = null;
		
		int score1 = 0;
		
		int score2 = 0;
		
		for(int i=0;i<p1.getSize();i++ ){
			
			resultat = play(p1.getNextMove(), p2.getNextMove());
			
			switch(resultat){
			
			case WIN:
				
				score1++;
				p1.setScore(score1);
				break;
				
			case TIE:
				
				break;
				
			case LOST:
	
				score2++;
				p2.setScore(score2);
				break;
			
			
			}
			
		}
		
		if(score1>score2)       resultat = Result.WIN;
		else if(score1<score2)  resultat = Result.LOST;
		else if(score1==score2) resultat = Result.TIE;
		
		
		return resultat;
		
	}

}
